﻿begin
{}
process
{
    $basePath=Split-Path -Parent $PSCommandPath
    $filename = "$basePath\Assemblies\Mono.Cecil.dll"
    $cecilAssembly = [System.Reflection.Assembly]::LoadFrom($filename)
    
    $assemblyPath=$_

    $assemblyDefinition= [Mono.Cecil.AssemblyDefinition]::ReadAssembly($assemblyPath)
    $frameworkVersionAttribute=$assemblyDefinition.CustomAttributes | Where-Object {$_.AttributeType.FullName -eq "System.Runtime.Versioning.TargetFrameworkAttribute"}
    $runtimeVersionAttribute = $assemblyDefinition.MainModule.RuntimeVersion;

    if($frameworkVersionAttribute -eq $null)
    {
        $frameworkVersion=$frameworkVersionAttribute.Properties[0].Argument.Value;
    }
    else
    {
        $frameworkVersion="N/A"   
    }

    New-Object -TypeName PSObject -Property @{AssemblyPath=$assemblyPath;
                                              FrameworkVersion=$frameworkVersion;
                                              RuntimeVersion=$runtimeVersionAttribute;}
}